package com.example.bit.spring_ioc_demo;

import com.example.bit.spring_ioc_demo.ComponentDemo.ComponentDemo;
import com.example.bit.spring_ioc_demo.ConfigurationDemo.ConfigurationDemo;
import com.example.bit.spring_ioc_demo.ControllerDemo.ControllerDemo;
import com.example.bit.spring_ioc_demo.DemoUserInfo.UserInfo;
import com.example.bit.spring_ioc_demo.RepositoryDemo.RepositoryDemo;
import com.example.bit.spring_ioc_demo.ServiceDemo.ServiceDemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;

@SpringBootApplication
public class SpringIoCDemoApplication {

    public static void main(String[] args) {

        ApplicationContext context=SpringApplication.run(SpringIoCDemoApplication.class, args);
//        ControllerDemo controller = context.getBean(ControllerDemo.class);
//        controller.run();
//        ServiceDemo serviceDemo = (ServiceDemo)context.getBean("serviceDemo");//默认为类名小驼峰
//        serviceDemo.run();
//        RepositoryDemo repositoryDemo = context.getBean("repositoryDemo", RepositoryDemo.class);
//        repositoryDemo.run();
//        ConfigurationDemo configurationDemo = context.getBean(ConfigurationDemo.class);
//        configurationDemo.run();
//        ComponentDemo componentDemo =(ComponentDemo)context.getBean("componentDemo");
//        componentDemo.run();
        UserInfo putUser1 = (UserInfo)context.getBean("putUser1");
        System.out.println(putUser1.toString());
        UserInfo putUser2= (UserInfo)context.getBean("putUser2");
        System.out.println(putUser2.toString());
        UserInfo putUser3= (UserInfo)context.getBean("putUser3");
        System.out.println(putUser3.toString());
    }

}
